'''
绘制平面直角坐标系 Rectangular Coordinates
'''
import turtle as _t
import time as _time

def _rc_goto(x, y):  # 移动到某点，不留轨迹的函数
    _t.penup()
    _t.goto(x, y)
    _t.pendown()

def _rc_mov(x, y, rc_seth, length):  # 直线运动函数，移动到原点两个值，方向，长度两个值
    _rc_goto(x, y)
    _t.seth(rc_seth)  # 绝对角度
    _t.fd(length)  # 移动长度

def _draw_rc():  # Rectangular Coordinates直角坐标系简称
    scwide = 600  # 屏幕宽度
    scheight = 600  # 屏幕高度

    _rc_mov(scwide/2, 0, 180, scwide)  # 画横轴及箭头
    _rc_mov(scwide/2, 0, 135, scwide/30)
    _rc_mov(scwide/2, 0, 225, scwide/30)

    _rc_mov(0, scheight/2, -90, scheight)  # 画纵轴及箭头
    _rc_mov(0, scheight/2, 225, scwide/30)
    _rc_mov(0, scheight/2, 315, scwide/30)

    _rc_goto(scwide/2-10, -40)  # 写个“X”
    _t.write("X",  font=("Times", 12, "bold"))

    _rc_goto(30, scheight/2-30)  # 写个“Y”
    _t.write("Y",  font=("Times", 12, "bold"))

    _rc_goto(-40, -40)  # 写个“0”
    _t.write("O",  font=("Times", 12, "bold"))

    for i in range(-300, 300, 50):
        if i == 0:
            pass
        else:
            _rc_mov(i, -5, 90, 10)
            _t.write(i, font=("Times", 9, "bold"))
            _rc_mov(-5, i, 0, 10)
            _rc_goto(15, i-5)
            _t.write(i, font=("Times", 9, "bold"))
    _t.penup()
    _t.home()

def draw_rc():
    _t.tracer(0)
    _t.pencolor("green")
    _t.pensize("2")
    _draw_rc()
    _t.update()
    _t.tracer(1)
    _t.pendown()
    _t.pencolor("black")
    _t.pensize(1)
    _time.sleep(0.5)
    